{extend name="mainadmin@layouts/base" /}
{block name="main" }
<header class="header  b-b clearfix">
     <div class="page-breadcrumbs">
            <ul class="breadcrumb" >
                <li>
                    <i class="fa fa-ellipsis-v"></i>
                    <strong>用户设置</strong>
                </li>
            </ul>
      </div>
</header>
<form class="form-horizontal form-validate form_vbox" method="post" action="{:url('save')}">
    <section class="vbox">
        <section class="scrollable  wrapper w-f">
            <section class="panel panel-default">
                <header>
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#basic" data-toggle="tab">基本设置</a></li>
                        <li><a href="#withdraw" data-toggle="tab">提现设置</a></li>
                        <li><a href="#register" data-toggle="tab">注册协议</a></li>
                    </ul>
                </header>
                <div class="tab-content">
                    <div class="tab-pane active" id="basic">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">注册相关：</label>
                            <div class="controls">
                                <label class="radio-inline">
                                    <input name="register_status" value="0" {$setting['register_status']==0?'checked':''}
                                    type="radio" >关闭注册
                                </label>
                                <label class="radio-inline">
                                    <input name="register_status" value="1" {$setting['register_status']==1?'checked':''}
                                    type="radio">开放注册
                                </label>

                            </div>
                        </div>
                        <div class="form-group hide">
                            <label class="col-sm-2 control-label">注册赠送购物分：</label>
                            <div class="controls">
                                <input type="text" value="0" min=0 size="10"
                                       data-rule-required="true" data-rule-integer="true" name="register_integral">
                                <span class="help-line">用户注册赠送购物分</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">注册填写邀请码：</label>
                            <div class="controls">
                                <div>
                                    <label class="radio-inline">
                                        <input name="register_invite_code" value="0" {$setting['register_invite_code']==0?'checked':''}
                                        type="radio" >关闭(注册页不显示邀请码输入框，不影响分享绑定上下级)
                                    </label>
                                </div>
                                <label class="radio-inline">
                                    <input name="register_invite_code" value="1" {$setting['register_invite_code']==1?'checked':''}
                                    type="radio">填写邀请码
                                </label>
                                <label class="radio-inline">
                                    <input name="register_invite_code" value="2" {$setting['register_invite_code']==2?'checked':''}
                                    type="radio">填写用户ID
                                </label>
                                <label class="radio-inline">
                                    <input name="register_invite_code" value="3" {$setting['register_invite_code']==3?'checked':''}
                                    type="radio">填写用户手机号码
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">注册必须邀请：</label>
                            <div class="controls">
                                <label class="radio-inline">
                                    <input name="register_must_invite" value="0" {$setting['register_must_invite']==0?'checked':''}
                                    type="radio" >不强制
                                </label>
                                <label class="radio-inline">
                                    <input name="register_must_invite" value="1" {$setting['register_must_invite']==1?'checked':''}
                                    type="radio">强制填写
                                </label>
                                <span class="help-inline">注册填写邀请码【关闭】时此项不生效</span>
                            </div>
                        </div>
                        <div class="form-group m-t hide">
                            <label class="col-sm-2  control-label">绑定关系时间：</label>
                            <div class="controls">
                                <label class="radio-inline">
                                    <input name="bind_pid_time" value="0" {$setting['bind_pid_time']==0?'checked':''}
                                    type="radio"> 注册
                                </label>
                                <label class="radio-inline">
                                    <input name="bind_pid_time" value="1" {$setting['bind_pid_time']==1?'checked':''}
                                    type="radio"> 订单支付后
                                </label>
                            </div>
                        </div>
                        <div class="form-group m-t hide">
                            <label class="col-sm-2  control-label">分享绑定规则：</label>
                            <div class="controls">
                                <label class="radio-inline">
                                    <input name="bind_share_rule" value="0" {$setting['bind_share_rule']==0?'checked':''}
                                    type="radio"> 按最先分享绑定
                                </label>
                                <label class="radio-inline">
                                    <input name="bind_share_rule" value="1" {$setting['bind_share_rule']==1?'checked':''}
                                    type="radio"> 按最后分享绑定
                                </label>
                                <span class="help-inline">此项只支持微信访问，非微信访问按当前分享来源绑定</span>
                            </div>
                        </div>
                        <div class="line line-dashed line-lg pull-in" style="width:99%;"></div>
                        <div class="form-group hide">
                            <label class="col-sm-2 control-label">是否开放签到：</label>
                            <div class="controls">
                                <label class="radio-inline">
                                    <input name="sign_in" value="1" class="js_radio_undertake" data-class="sign_in_box"
                                           {$setting['sign_in']==1?'checked':''} type="radio">开放
                                </label>
                                <label class="radio-inline">
                                    <input name="sign_in" value="0" class="js_radio_undertake" {$setting['sign_in']==0?'checked':''}
                                    type="radio" >关闭
                                </label>
                            </div>
                        </div>
                        <div class="radio_undertake_sign_in sign_in_box {$setting['sign_in']==1?'':'hide'}">
                            <div class="form-group ">
                                <label class="col-sm-2 control-label">签到赠送购物分：</label>
                                <div class="controls">
                                    <input type="text" value="{$setting['sign_integral']}" class="input-ssmall" min=0
                                           data-rule-required="true" data-rule-integer="true" name="sign_integral">
                                    <span class="help-line"> 签到赠送的购物分</span>
                                </div>
                            </div>
                            <div class="form-group ">
                                <label class="col-sm-2 control-label">连续签到额外赠送：</label>
                                <div class="controls">
                                    <a href="javascript:;" title="增加" class="btn btn-default add_sign_constant"><i
                                            class="fa fa-plus"></i> 添加连续签到设置</a>
                                </div>
                            </div>
                            <div class="form-group ">
                                <label class="col-sm-2 control-label"></label>
                                <div class="controls constant_list">
                                    <ul>
                                        {volist name="$setting.sign_constant" id="constant" }
                                        <li>
                                            连续签收：
                                            <span class="input_relative">
                                            <input type="text" name="sign_constant[{$i}][day]" value="{$constant.day}"
                                                   class="input-ssmall" min=1 max=31 data-rule-required="true"
                                                   data-rule-integer="true" name="sign_integral">
                                        </span>
                                            天，额外赠送：
                                            <span class="input_relative">
                                    <input type="text" name="sign_constant[{$i}][integral]" value="{$constant.integral}"
                                           class="input-ssmall" min=1 max=1000 data-rule-required="true"
                                           data-rule-integer="true" name="sign_integral">
                                    </span>
                                            购物分
                                            <a href="javascript:;" title="增加"
                                               class="btn btn-default fa fa-times del_sign_consgant"></a>
                                        </li>
                                        {/volist}
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="tab-pane " id="withdraw">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">是否开启提现：</label>
                            <div class="controls">
                                <label class="radio-inline">
                                    <input name="withdraw_status" value="1" {$setting['withdraw_status']==1?'checked':''}
                                    type="radio">开启
                                </label>
                                <label class="radio-inline">
                                    <input name="withdraw_status" value="0" {$setting['withdraw_status']==0?'checked':''}
                                    type="radio" >关闭
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" >提现方式：</label>
                            <div class="col-sm-10">
                                <label class="radio-inline">
                                    <input type="checkbox" name="withdraw_type[]" value="0" {if in_array(0,$setting.withdraw_type) }checked{/if} >银行卡
                                </label>
                                <label class="radio-inline">
                                    <input type="checkbox" name="withdraw_type[]" value="1" {if in_array(1,$setting.withdraw_type) }checked{/if} >微信
                                </label>
                                <label class="radio-inline">
                                    <input type="checkbox" name="withdraw_type[]" value="2" {if in_array(2,$setting.withdraw_type) }checked{/if} >支付宝
                                </label>
                            </div>
                        </div>
                        <div class="form-group ">
                        <label class="col-sm-2 control-label">开启提现周期：</label>
                        <div class="controls">
                            <input name="withdraw_week_1" value="0" type="hidden">
                            <input name="withdraw_week_2" value="0" type="hidden">
                            <input name="withdraw_week_3" value="0" type="hidden">
                            <input name="withdraw_week_4" value="0" type="hidden">
                            <input name="withdraw_week_5" value="0" type="hidden">
                            <input name="withdraw_week_6" value="0" type="hidden">
                            <input name="withdraw_week_0" value="0" type="hidden">
                            <label class="radio-inline">
                                <input name="withdraw_week_1" value="1" type="checkbox" {$setting['withdraw_week_1']==1?'checked':''}>星期一
                            </label>
                            <label class="radio-inline">
                                <input name="withdraw_week_2" value="1" type="checkbox" {$setting['withdraw_week_2']==1?'checked':''}>星期二
                            </label>
                            <label class="radio-inline">
                                <input name="withdraw_week_3" value="1" type="checkbox" {$setting['withdraw_week_3']==1?'checked':''}>星期三
                            </label>
                            <label class="radio-inline">
                                <input name="withdraw_week_4" value="1" type="checkbox" {$setting['withdraw_week_4']==1?'checked':''}>星期四
                            </label>
                            <label class="radio-inline">
                                <input name="withdraw_week_5" value="1" type="checkbox" {$setting['withdraw_week_5']==1?'checked':''}>星期五
                            </label>
                            <label class="radio-inline">
                                <input name="withdraw_week_6" value="1" type="checkbox" {$setting['withdraw_week_6']==1?'checked':''}>星期六
                            </label>
                            <label class="radio-inline">
                                <input name="withdraw_week_0" value="1" type="checkbox" {$setting['withdraw_week_0']==1?'checked':''}>星期天
                            </label>
                            <span class="help-line"> </span>
                        </div>
                    </div>
                    <div class="form-group ">
                        <label class="col-sm-2 control-label">每天开放时间：</label>
                        <div class="controls">
                            <input type="text" value="{$setting['withdraw_day_start']}" min=0  size="10" data-rule-required="true" data-rule-integer="true" name="withdraw_day_start"> 点 -
                            <input type="text" value="{$setting['withdraw_day_stop']}" min=0  size="10" data-rule-required="true" data-rule-integer="true" name="withdraw_day_stop"> 点
                            <span class="help-line"> 24小时制,例如晚上九点请写21</span>
                        </div>
                    </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">提现倍数：</label>
                            <div class="controls">
                                 <label class="radio-inline">
                                    <input name="withdraw_multiple" value="0" {$setting['withdraw_multiple']==0?'checked':''} type="radio"
                                    >关闭
                                </label>
                                <label class="radio-inline">
                                    <input name="withdraw_multiple" value="1" {$setting['withdraw_multiple']==1?'checked':''}
                                    type="radio">10倍数
                                </label>
                                <label class="radio-inline">
                                    <input name="withdraw_multiple" value="2" {$setting['withdraw_multiple']==2?'checked':''} type="radio"
                                    >50倍数
                                </label>
                                <label class="radio-inline">
                                    <input name="withdraw_multiple" value="3" {$setting['withdraw_multiple']==3?'checked':''} type="radio"
                                    >100倍数
                                </label>
                            </div>
                        </div>
                        <div class="form-group ">
                            <label class="col-sm-2 control-label">最低提现金额：</label>
                            <div class="controls">
                                <input type="text" value="{$setting['withdraw_min_money']}" min=0 size="10"
                                       data-rule-required="true" data-rule-integer="true" name="withdraw_min_money">
                                <span class="help-line"> 金额必须达到最低提现金额，才能申请提现</span>
                            </div>
                        </div>
                        <div class="form-group ">
                            <label class="col-sm-2 control-label">最高提现金额：</label>
                            <div class="controls">
                                <input type="text" value="{$setting['withdraw_max_money']}" min=0 size="10"
                                       data-rule-required="true" data-rule-integer="true" name="withdraw_max_money">
                                <span class="help-line"> 单次提现金额不能超过此金额，才能申请提现</span>
                            </div>
                        </div>
                        <div class="form-group ">
                            <label class="col-sm-2 control-label">提现手续费：</label>
                            <div class="controls">
                                <input type="text" value="{$setting['withdraw_fee']}" min=0 size="10"
                                       data-rule-required="true" data-rule-ismoney="true" name="withdraw_fee">
                                <span class="help-line"> %（注：如填1就是 代表每笔提现，收取提现金额1%的手续费）</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">手续费扣除方式：</label>
                            <div class="controls">
                                <label class="radio-inline">
                                    <input name="withdraw_fee_type" value="1" {$setting['withdraw_fee_type']==1?'checked':''}
                                    type="radio">内扣
                                </label>
                                <label class="radio-inline">
                                    <input name="withdraw_fee_type" value="0" {$setting['withdraw_fee_type']==0?'checked':''} type="radio"
                                    >外扣
                                </label>
                                <span class="help-line"> %（注：例如手续费8%,外扣:提100扣108积分到账100,内扣提100扣100积分到账92）</span>
                            </div>
                        </div>
                        <div class="form-group ">
                            <label class="col-sm-2 control-label">最低手续费：</label>
                            <div class="controls">
                                <input type="text" value="{$setting['withdraw_fee_min']}" min=0 size="10"
                                       data-rule-required="true" data-rule-ismoneyy="true" name="withdraw_fee_min">
                                <span class="help-line"> （注：单笔手续费计算出来小于该值时，则取该值）</span>
                            </div>
                        </div>
                        <div class="form-group ">
                            <label class="col-sm-2 control-label">最高手续费：</label>
                            <div class="controls">
                                <input type="text" value="{$setting['withdraw_fee_max']}" min=0 size="10"
                                       data-rule-required="true" data-rule-ismoney="true" name="withdraw_fee_max">
                                <span class="help-line"> （注：单笔手续费计算出来大于该值时，则取该值,为0时则不限）</span>
                            </div>
                        </div>
                        <div class="form-group ">
                            <label class="col-sm-2 control-label">每日累计提现次数：</label>
                            <div class="controls">
                                <input type="text" value="{$setting['withdraw_num']|intval}" min=0 size="10"
                                       data-rule-required="true" data-rule-ismoney="true" name="withdraw_num">
                                <span class="help-line"> （注：单人每日累计提现次数达到该值时，本日将不支持继续提现,为0时则不限）</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">转款类型：</label>
                            <div class="controls">
                                <label class="radio-inline">
                                    <input name="transfer_status" value="0" {$setting['transfer_status']==0?'checked':''}
                                    type="radio" >人工转账
                                </label>
                                <label class="radio-inline">
                                    <input name="transfer_status" value="1" {$setting['transfer_status']==1?'checked':''}
                                    type="radio">灵工平台
                                </label>
                            </div>
                        </div>
                        <div class="form-group transfer hide">
                            <label class="col-sm-2 control-label">灵工平台APPID：</label>
                            <div class="controls">
                                <input type="text" value="{$setting['transfer_app_id']}"
                                       data-rule-required="true" name="transfer_app_id" style="width: 300px;">
                            </div>
                        </div>
                        <div class="form-group transfer hide">
                            <label class="col-sm-2 control-label">灵工平台APPSECRET：</label>
                            <div class="controls">
                                <input type="text" value="{$setting['transfer_app_secret']}"
                                       data-rule-required="true" name="transfer_app_secret" style="width: 300px;">
                            </div>
                        </div>
                    </div>
                    <div class="tab-pane " id="register">
                        <div style="width: 352px;">
                            <div id="register_agreement"></div>
                            <textarea rows="13" class="hd" data-toggle="ueditor" data-div="register_agreement" data-height="450" data-maximumwords="50000" name="register_agreement" >{$setting['register_agreement']|raw}</textarea>
                        </div>
                        <div >移动端的图片建议宽度为750像素</div>
                    </div>
                </div>
            </section>
        </section>
        <footer class="footer bg-white b-t p-t">
            <div class="form-group">
                <div class="col-sm-4 col-sm-offset-1">
                    <button type="submit" class="btn btn-primary js_save_submit" data-loading-text="保存中...">保存</button>
                    <button type="button" class="btn btn-default" data-toggle="back">取消</button>
                </div>
            </div>
        </footer>
    </section>
</form>
{literal}
<script type="text/html" id="constant_list_li">
    <li>
        连续签收：
        <span class="input_relative">
            <input type="text" name="sign_constant[{{i}}][day]" value="" class="input-ssmall" min=1 max=31 data-rule-required="true" data-rule-integer="true" name="sign_integral">
        </span>
        天，额外赠送：
        <span class="input_relative">
             <input type="text" name="sign_constant[{{i}}][integral]" value="" class="input-ssmall" min=1 max=1000 data-rule-required="true" data-rule-integer="true" name="sign_integral">
        </span>
        购物分
        <a href="javascript:;" title="增加" class="btn btn-default fa fa-times del_sign_consgant"></a>
    </li>
</script>
{/literal}
<script type="text/javascript">
    var sign_constant_length = $('.constant_list li').length;
    $('.add_sign_constant').click(function () {
        var arr = new Object();
        sign_constant_length++;
        arr.i = sign_constant_length;
        $('.constant_list ul').append(template('constant_list_li',arr));
    })
    $(document).on('click','.del_sign_consgant',function () {
        $(this).parent('li').remove();
    })

    var goods_type = $("input[name='transfer_status']:checked").val();
    changeType(goods_type);
    $("input[name='transfer_status']").on('change',function(){
        goods_type = $(this).val();
        changeType(goods_type);
    })

    function changeType(goods_type) {
        if(goods_type==0){
            $('.transfer').addClass('hide');
        }else{
            $('.transfer').removeClass('hide');
        }
    }

</script>
{/block}
